package com.sugar.follow.up.module.business.controller.admin.userpatient.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.sugar.follow.up.module.business.enums.DictTypeConstants;
import com.sugar.follow.up.module.business.framework.web.convert.ListToStringConverter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.time.LocalDate;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import cn.idev.excel.annotation.*;
import com.sugar.follow.up.framework.excel.core.annotations.DictFormat;
import com.sugar.follow.up.framework.excel.core.convert.DictConvert;

import static com.sugar.follow.up.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static com.sugar.follow.up.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.sugar.follow.up.module.infra.enums.DictTypeConstants.BOOLEAN_STRING;

@Schema(description = "管理后台 - 就诊人 Response VO")
@Data
@ExcelIgnoreUnannotated
public class UserPatientRespVO {

    @Schema(description = "就诊人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25165")
    @ExcelProperty("就诊人ID")
    private Long id;

    @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16109")
    @ExcelProperty("用户ID")
    private Long userId;

    @Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
    @ExcelProperty("姓名")
    private String name;

    @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("手机号")
    private String mobile;

    @Schema(description = "身份证号", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("身份证号")
    private String idCard;

    @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("出生日期")
    @JsonSerialize(using = LocalDateSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate birthday;

    @Schema(description = "省市区（逗号分隔）", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "省市区", converter = ListToStringConverter.class)
    private List<String> location;

    @Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("详细地址")
    private String locationDetail;

    @Schema(description = "ID号", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("ID号")
    private String idCode;

    @Schema(description = "确诊年龄", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("确诊年龄")
    private String confirmedDiagnosisAge;

    @Schema(description = "特病症（0否 1是）", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "是否特病症", converter = DictConvert.class)
    @DictFormat(BOOLEAN_STRING)
    private Boolean specialIllness;

    @Schema(description = "心脑血管系统既往病史（字典：business_user_patient_xnxg_type）")
    @ExcelProperty(value = "心脑血管系统既往病史", converter = ListToStringConverter.class)
    private List<String> xnxgHistory;

    @Schema(description = "神经系统既往病史（字典：business_user_patient_sj_type）")
    @ExcelProperty(value = "神经系统既往病史", converter = ListToStringConverter.class)
    private List<String> sjHistory;

    @Schema(description = "呼吸系统既往病史（字典：business_user_patient_hx_type）")
    @ExcelProperty(value = "呼吸系统既往病史", converter = ListToStringConverter.class)
    private List<String> hxHistory;

    @Schema(description = "消化系统既往病史（字典：business_user_patient_xh_type）")
    @ExcelProperty(value = "消化系统既往病史", converter = ListToStringConverter.class)
    private List<String> xhHistory;

    @Schema(description = "血液系统既往病史（字典：business_user_patient_xy_type）")
    @ExcelProperty(value = "血液系统既往病史", converter = ListToStringConverter.class)
    private List<String> xyHistory;

    @Schema(description = "内分泌系统既往病史（字典：business_user_patient_nfm_type）")
    @ExcelProperty(value = "内分泌系统既往病史", converter = ListToStringConverter.class)
    private List<String> nfmHistory;

    @Schema(description = "其它既往病史")
    @ExcelProperty("其它既往病史")
    private String otherHistory;

    @Schema(description = "常用药物")
    @ExcelProperty("常用药物")
    private String commonlyUsedDrugs;

    @Schema(description = "主要病症")
    @ExcelProperty("主要病症")
    private String mainSymptoms;

    @Schema(description = "初始：tPSA（ng／ml）")
    @ExcelProperty("初始 tPSA（ng／ml）")
    private String initialTpsa;

    @Schema(description = "睾酮（nmol／L）")
    @ExcelProperty("睾酮（nmol／L）")
    private String testosterone;

    @Schema(description = "MRI")
    @ExcelProperty("MRI")
    private String mri;

    @Schema(description = "穿刺病理")
    @ExcelProperty("穿刺病理")
    private String puncturePathology;

    @Schema(description = "临床诊断")
    @ExcelProperty("临床诊断")
    private String clinicalDiagnosis;

    @Schema(description = "危险分层")
    @ExcelProperty("危险分层")
    private String riskStratification;

    @Schema(description = "首选治疗方案（字典：business_user_patient_preferred_plan）")
    @ExcelProperty(value = "首选治疗方案", converter = DictConvert.class)
    @DictFormat(DictTypeConstants.BUSINESS_USER_PATIENT_PRE_PLAN)
    private Integer preferredPlan;

    @Schema(description = "状态（0待分配 1已分配）", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
    @ExcelProperty(value = "是否已分配", converter = DictConvert.class)
    @DictFormat(BOOLEAN_STRING)
    private Boolean status;

    @Schema(description = "分配的医生ID", example = "27963")
    @ExcelIgnore
    private Long doctorId;

    @Schema(description = "分配的医生姓名", example = "27963")
    @ExcelProperty("分配的医生")
    private String doctorName;

    @Schema(description = "风险等级（字典：business_user_patient_risk_level）")
    @ExcelProperty(value = "风险等级", converter = DictConvert.class)
    @DictFormat(DictTypeConstants.BUSINESS_USER_PATIENT_RISK_LEVEL)
    private String riskLevel;

    @Schema(description = "就诊人标签")
    private List<List<String>> tags;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    @Schema(description = "备注")
    @ExcelProperty("备注")
    private String remark;
}
